﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace A_Modules.XMLSerialize
{
    class XMLSerialize
    {
        public void Test()
        {
            string outputfile =
                @"D:\DevProjects\Myprojects\DotNet\iceternally-dotnet-test\trunk\BaseLab\BaseLab20\A-Modules\XMLSerialize\Datainfo.xml";

            using(XmlTextWriter _xmlWriter = new XmlTextWriter(outputfile,Encoding.UTF8))
            {
                _xmlWriter.Formatting = Formatting.Indented;//缩进？
                DataInfo df = new DataInfo();
                df.Test1 = "test hehe123";
                df.dic = new DataInfoChild();
                
                df.dic.tc1 = 33;
                df.dic.tc2 = "haha";

                df.list = new List<string>();
                df.list.Add("1");
                df.list.Add("3");
                df.list.Add("5");


                df.listchild = new List<DataInfoChild>();

                df.listchild.Add(new DataInfoChild());
                df.listchild.Add(new DataInfoChild("hh"));


                df.dicChild = new Dictionary<string, DataInfoChild>();

                df.dicChild.Add("Name1",new DataInfoChild("hh"));

                XmlSerializer _xmlSerializer = new XmlSerializer(typeof(DataInfo));

                _xmlSerializer.Serialize(_xmlWriter, df);

            }
;

            

        }

        //public 
    }
}
